#ifndef  _ATA_H_
#define  _ATA_H_

#include <map>
#include <list>
using std::map;
using std::list;

#include <pthread.h>
#include <pcap.h>

//Arp Scan & Atack

class asa{

public:
	int init();
	int run();
	int stop();
	list<unsigned int> * query_online_host();
	void attack(unsigned int ip);

	asa():init_success(false),running(false)
	{
		pthread_rwlock_init(&table_lock, NULL);
	}
	~asa()
	{
		if(running)
		{
			stop();
		}
		pcap_close(pcap_fd);
		pthread_rwlock_destroy(&table_lock);
	}

	void* arp_scan_thread();	//scan host in lan
	void* arp_sniff_thread();	//sniff arp reply

private:
	bool init_success;
	bool running;
	pthread_t arp_scan_tid;
	pthread_t arp_sniff_tid;
	pcap_t *pcap_fd;			// Session handle 
	char *dev;				// The device to sniff on 
	unsigned int ip_self;
	unsigned int gateway;		// ip of gateway	
	unsigned int mask;		// netmask 
	unsigned int net;			// network number	
	mac_t mac_self;

	map<unsigned int, mac_t>	ip_mac_table;
	pthread_rwlock_t 	table_lock;
};



#endif

